package com.qys.livesMall.shop.controller.sys;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qys.livesMall.common.exception.QysException;
import com.qys.livesMall.common.result.R;
import com.qys.livesMall.common.utils.MessageUtils;
import com.qys.livesMall.framework.utils.SecurityUtils;
import com.qys.livesMall.shop.enums.ShopMessageEnum;
import com.qys.livesMall.shop.modal.dto.task.app.SellTaskShopPageDTO;
import com.qys.livesMall.shop.modal.dto.task.sys.SysShopSellTaskPageDTO;
import com.qys.livesMall.shop.modal.entity.H2ShopBase;
import com.qys.livesMall.shop.modal.vo.task.app.SellTaskShopPageVo;
import com.qys.livesMall.shop.modal.vo.task.sys.SysShopSellTaskPageVo;
import com.qys.livesMall.shop.service.ShopSellTaskService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@Tag(name = "后台管理-带货任务")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping("/sys/shop/sell/task")
public class SysShopSellTaskController {


    private final ShopSellTaskService shopSellTaskService;


    @PostMapping("/sellTaskPage")
    @Operation(summary = "分页查询带货任务列表")
    public R<Page<SysShopSellTaskPageVo>> sellTaskPage(@RequestBody SysShopSellTaskPageDTO queryDTO) {
        return R.ok(shopSellTaskService.pageBySys(queryDTO));
    }

    @PutMapping("/pass/{id}")
    @Operation(summary = "带货任务通过审核", parameters = {@Parameter(name = "id", description = "带货任务id")})
    public R<?> pass(@PathVariable Long id) {
        if (shopSellTaskService.pass(id)==1){
            return R.ok(MessageUtils.message("审核时间已超过带货结束日期,已拒绝通过"));
        }
        return R.ok();
    }


    @PutMapping("/noPass/{id}")
    @Operation(summary = "带货任务未通过审核", parameters = {@Parameter(name = "id", description = "带货任务id")})
    public R<Void> noPass(@PathVariable Long id) {
        shopSellTaskService.noPass(id);
        return R.ok();
    }


}
